/*
 * Copyright (C) 2015-2019 Alibaba Group Holding Limited
 */

#ifndef CAN_BUS_H_
#define CAN_BUS_H_
#include <stdint.h>
#include "aos/kernel.h"
#include "aos/hal/can.h"
#include "aos/list.h"

#define CAN_SEND_BLOCK_MS 1000
#define CAN_DEMO_TASK_DEPTH 2048

#ifdef __cplusplus
extern "C" {
#endif

typedef struct{
	int8_t id;
	
	int32_t (*canbus_send)(const can_frame_t *frame);
	void    *send_mutex;

	can_frame_t *can_rx_pbuf;
	aos_queue_t can_rx_queue;

	uint32_t dev_num;

	slist_t  bus_l;
	void    *bus_mutex;
	
} canbus_t;

typedef struct {
	slist_t     next;
	void       *sem_t;
	uint32_t    rx_id;
	uint8_t    *rx_buf;
	canbus_t   *bus;
} canbus_dev_t;



int32_t canbus_init(void);
int32_t canbus_send(const can_frame_t *frame);


#ifdef __cplusplus
}
#endif

#endif /* CAN_BUS_H_ */

